package com.example.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CalcController {

    //实现一个计算器
    @RequestMapping("/calc")
    public String add(Integer num1,Integer num2) {
        if(num1 == null || num2 == null) return "<h1>结果： 参数出错 </h1>"+"<a href='javascript:history.go(-1);'>返回</a>";
        return "<h1>结果：" + (num1 + num2) + "</h1><a href='javascript:history.go(-1);'>返回</a>";
    }
}
